﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:mes="http://www.wales.nhs.uk/namespaces/MessageRelease2"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
  xmlns:nwisdocs="http://wales.nhs.uk/nwis/docs">
  <xsl:output method="xml" indent="yes" />
  
  <xsl:template match="/">
    
      <mes:DocumentVersion>
        <mes:Header>
          <mes:DocumentId>00000000-0000-0000-0000-000000000000</mes:DocumentId>
          <mes:DocumentSupersessionSetId>00000000-0000-0000-0000-000000000000</mes:DocumentSupersessionSetId>
          <mes:DocumentDateTime>2011-09-13T14:06:00.749+01:00</mes:DocumentDateTime>
          <mes:MIMEtype>application/xml</mes:MIMEtype>
          <mes:VersionNumber>0</mes:VersionNumber>
          <mes:VersionDescription />
          <mes:SensitivityTypeCode></mes:SensitivityTypeCode>
          <mes:RenderingCode />
          <mes:LocationCode />
          <mes:Revoked>false</mes:Revoked>
          
          <mes:DocumentAttribute>
            <mes:Attribute>DocumentTypeCode</mes:Attribute>
            <mes:Namespace>http://test</mes:Namespace>
            <mes:Value>
              <xsl:value-of select="//nwisdocs:DocumentHeader/nwisdocs:DocumentData/nwisdocs:DocumentCategory/nwisdocs:DocumentSubTypeCode"/>
            </mes:Value>
            <mes:ValueDomain />
          </mes:DocumentAttribute>
          <mes:SubjectDemographicsAsRecorded>

            <mes:SubjectIdentifier>
              <mes:Domain>NHS</mes:Domain>
              <mes:Value>
                <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:NHSnumber/nwisdocs:IdValue" />
              </mes:Value>
            </mes:SubjectIdentifier>
            <mes:SubjectIdentifier>
              <mes:Domain>
                <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:PatientId/nwisdocs:IdType" />
              </mes:Domain>
              <mes:Value>
                <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:PatientId/nwisdocs:IdValue" />
              </mes:Value>
            </mes:SubjectIdentifier>

            <mes:FamilyName>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:FormalName/nwisdocs:StructuredName/nwisdocs:FamilyName" />
            </mes:FamilyName>
            <mes:GivenName>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:FormalName/nwisdocs:StructuredName/nwisdocs:GivenName" />
            </mes:GivenName>
            <mes:DateOfBirth>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:DateOfBirth" />
            </mes:DateOfBirth>
            <mes:SexCode>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:Gender" />
            </mes:SexCode>
            <mes:AddressLine1>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:Address/nwisdocs:StructuredAddress/nwisdocs:AddressLine[0]" />
            </mes:AddressLine1>
            <mes:AddressLine2>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:Address/nwisdocs:StructuredAddress/nwisdocs:AddressLine[1]" />
            </mes:AddressLine2>
            <mes:AddressLine3>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:Address/nwisdocs:StructuredAddress/nwisdocs:AddressLine[2]" />
            </mes:AddressLine3>
            <mes:AddressLine4>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:Address/nwisdocs:StructuredAddress/nwisdocs:AddressLine[3]" />
            </mes:AddressLine4>
            <mes:Postcode>
              <xsl:value-of select="//nwisdocs:PatientDetails/nwisdocs:Demographics/nwisdocs:Address/nwisdocs:PostCode" />
            </mes:Postcode>
          </mes:SubjectDemographicsAsRecorded>
        </mes:Header>
        <mes:Body>
            <xsl:copy-of select="."/>
        </mes:Body>
      </mes:DocumentVersion>
    
  </xsl:template>
</xsl:stylesheet>